<template>
	<view class="record">
		<view class="head">
			<view class="head1">请选择查询月份</view>
			<view class="con">
				<view class="left" @click="show=true">{{ date }}</view>
				<view class="right" @click="getAttendanceRecord">查询</view>
			</view>
		</view>
		<view class="list-content">
			<view class="item" v-for="(value,key) in data" :key="key">
				<view class="item-top">{{ date2+'-'+key }}</view>
				<view class="top" v-for="(item,index) in value" :key="index" @click="handleGoInfo(item.id)">
					<view class="top-1">
						<view class="top1">{{ item.userName }}</view>
						<view class="top1">网格：{{ item.gridName }}</view>
					</view>
					<view class="top-2">
						<view class="top1">打卡时间：{{ item.checkingDate }}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- -->
		<u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				date:'',
				date2:'',
				params: {
					year: true,
					month: true
				},
				data:{}
			}
		},
		onLoad() {
			let date = new Date();
			this.date = date.getFullYear() +'-'+(date.getMonth()+1)
		},
		mounted() {
			this.getAttendanceRecord()
		},
		methods:{
			confirm(e) {
				this.date = e.year + '-' + e.month
			},
			getAttendanceRecord() {
				let params = {
					date:this.date
				}
				this.date2 = this.date
				this.$u.api.getAttendanceRecord()
					.then(res => {
						// console.log(res)
						if(res.code == 200) {
							this.data = res.result
						}
					})
					.catch(err => {
						console.log(err)
					})
			},
			handleGoInfo(id) {
				console.log(id)
				uni.navigateTo({
					url:'../SignInInfo/SignInInfo?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.record{
		padding: 20rpx;
		background-color: #f5f6f7;
		min-height: 100vh;
		.head{
			.head1{
				color: #333;
				font-size: 28rpx;
				font-weight: 600;
			}
			.con{
				display: flex;
				justify-content: space-around;
				align-items: center;
				padding: 30rpx 0;
				.left{
					color: #999;
					font-size: 26rpx;
				}
				.right{
					width: 100rpx;
					height: 50rpx;
					border-radius: 10rpx;
					background-color: #007AFF;
					display: flex;
					justify-content: center;
					align-items: center;
					color: #fff;
					font-size: 27rpx;
				}
			}
		}
		.list-content{
			width: 100%;
			.item{
				width: 100%;
				border-radius: 0 5px 5px #eee,0 0 5px #eee,0 0 5px #eee;
				border-radius: 15rpx;
				margin-bottom: 20rpx;
				padding: 20rpx;
				color: #666;
				font-size: 27rpx;
				.item-top{
					color: #333;
					font-size: 27rpx;
					padding: 20rpx;
					font-weight: 600;
				}
				.top{
					background-color: #fff;
					display: flex;
					justify-content: space-between;
					align-items: flex-start;
					flex-direction: column;
					border-bottom: 1px solid #f4f1f1;
					border-radius: 20rpx;
					padding: 20rpx;
					width: 100%;
					.top-1{
						display: flex;
						justify-content: space-between;
						align-items: center;
						width: 100%;
						.top1{}
						margin-bottom: 20rpx;
					}
					.top-2{
						display: flex;
						justify-content: flex-end;
						align-items: flex-end;
						.top1{}
					}
				}
			}
		}
	}
</style>
